import { LinValidator, Rule } from 'lin-mizar';


class AddContentValidator extends LinValidator {
  constructor() {
    super();
    this.image = [
      new Rule('isNotEmpty', '内容封面不能为空'),
    ]
    this.type = [
      new Rule('isNotEmpty', '内容类型不能为空'),
      new Rule('isInt', '内容类型id必须为数字'),
    ]
    this.title = [
      new Rule('isNotEmpty', '内容标题不能为空'),
    ]
    this.content = [
      new Rule('isNotEmpty', '内容简介不能为空'),
    ]
    this.imageUrl = [
      new Rule('isOptional'),
      new Rule('isURL', '内容链接必须是合法的URL地址'),
    ]
    this.pubdate = [
      new Rule('isNotEmpty', '发布内容不能为空'),
      new Rule('isISO8601', '发布日期格式不正确'),
    ]
    this.status = [
      new Rule('isNotEmpty', '内容有效状态不能为空'),
      new Rule('isInt', '内容有效状态表示不正确'),
    ]
  }
}


class EditContentValidator extends AddContentValidator {
  constructor() {
    super();
    this.id = [
      new Rule('isNotEmpty', '内容id不能为空'),
      new Rule('isInt', '内容id表示不正确', { min: 1 }),
    ]
  }
}


class DeleteContentValidator extends LinValidator {
  constructor() {
    super();
    this.id = [
      new Rule('isNotEmpty', '内容id不能为空'),
      new Rule('isInt', '内容id表示不正确', { min: 1 }),
    ]
    this.type = [
      new Rule('isNotEmpty', '内容类型不能为空'),
      new Rule('isInt', '内容类型id必须为数字'),
    ]
  }
}


export { AddContentValidator, EditContentValidator, DeleteContentValidator };
